<template>
  <a-split class="h-full" default-size="300">
    <template #first>
      <use-code disabled :model-value="JSON.stringify(option, null, 2)" />
    </template>
    <template #second>
      <ECharts :option="option" />
    </template>
  </a-split>
</template>

<script lang="ts" setup>
import * as echarts from 'echarts'

const ECharts = createComponent({ echarts, h })
const option = reactive({
  title: {
    text: '',
  },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow',
    },
  },
  legend: {
    data: ['RED', 'BLUE'],
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true,
  },
  xAxis: {
    type: 'category',
    data: (function () {
      let list = []
      for (let i = 1; i <= 11; i++) {
        list.push('Nov ' + i)
      }
      return list
    })(),
  },
  yAxis: {
    type: 'value',
  },
  series: [
    {
      name: '隐藏的',
      type: 'bar',
      stack: 'Total',
      silent: true,
      itemStyle: {
        borderColor: 'transparent',
        color: 'transparent',
      },
      emphasis: {
        itemStyle: {
          borderColor: 'transparent',
          color: 'transparent',
        },
      },
      data: [0, 900, 1245, 1530, 1376, 1376, 1511, 1689, 1856, 1495, 1292],
    },
    {
      name: 'RED',
      type: 'bar',
      stack: 'Total',
      itemStyle: {
        color: 'red',
      },
      label: {
        show: true,
        position: 'top',
      },
      data: [900, 345, 393, '-', '-', 135, 178, 286, '-', '-', '-'],
    },
    {
      name: 'BLUE',
      type: 'bar',
      stack: 'Total',
      itemStyle: {
        color: 'blue',
      },
      label: {
        show: true,
        position: 'bottom',
      },
      data: ['-', '-', '-', 108, 154, '-', '-', '-', 119, 361, 203],
    },
  ],
})
</script>
